﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NullSuicide.Steps;

namespace NullSuicide
{
    public partial class Main : Form
    {
        private Players _players;
        private Step _currentStep;

        public Main()
        {
            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {
            _players = DataConnector.LoadPlayers();
            _players.sortlist();

            _currentStep = new SelectPlayers();
            _currentStep.LoadData(_players);

            ShowStep();                  
        }

        private void bNext_Click(object sender, EventArgs e)
        {
            if (_currentStep is SelectPlayers)
            {
                _currentStep.SaveData();
                _currentStep = new SuicidePlayers();
                _currentStep.LoadData(_players);

                ShowStep();

                bNext.Enabled = false;
                bPrevious.Enabled = true;
            }
        }

        private void bPrevious_Click(object sender, EventArgs e)
        {
            if (_currentStep is SuicidePlayers)
            {
                _currentStep.SaveData();
                _currentStep = new SelectPlayers();
                _currentStep.LoadData(_players);

                ShowStep();

                bNext.Enabled = true;
                bPrevious.Enabled = false;
            }
        }

        private void ShowStep()
        {
            gbCurrentStep.Controls.Clear();
            gbCurrentStep.Controls.Add(_currentStep);
            _currentStep.Dock = DockStyle.Fill;            
        }
    }
}
